import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编码',
    align:"center",
    dataIndex: 'code',
    width: '80px'
   },
   {
    title: '名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '零件图号',
    align:"center",
    dataIndex: 'partDrawingNo',
    width: '100px'
   },
   {
    title: '零件',
    align:"center",
    dataIndex: 'partName',
    width: '100px'
   },
   {
    title: '库位编号',
    align:"center",
    dataIndex: 'warehouseCode',
    width: '100px'
   },
   {
    title: '库位',
    align:"center",
    dataIndex: 'warehouseName',
    width: '100px'
   },
   {
    title: '维保冲次',
    align:"center",
    dataIndex: 'maintenanceCharge',
    width: '100px'
   },
   {
    title: '维保提前冲次',
    align:"center",
    dataIndex: 'maintenanceForwardCharge',
    width: '120px'
   },
   {
    title: '维保周期',
    align:"center",
    dataIndex: 'maintenanceCycle',
    width: '100px'
   },
   {
    title: '冲次系数',
    align:"center",
    dataIndex: 'chargeCoefficient',
    width: '100px'
   },
   {
    title: '当前冲次',
    align:"center",
    dataIndex: 'chargeCoefficient',
    width: '100px'
   },
   {
    title: '冲次总计',
    align:"center",
    dataIndex: 'chargeCoefficient',
    width: '100px'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
    customRender: ({text}) => text === 0 ? "上线" : text === 1 ? '空闲' : text === 2 ? "维保" : text === 3 ? '报废' : '',
    width: '80px'
   },
   {
    title: '上次维保时间',
    align:"center",
    dataIndex: 'status_dictText',
    width: '120px'
   },
   {
    title: '生产厂家',
    align:"center",
    dataIndex: 'manufacturerName',
    width: '100px'
   },
   {
    title: '使用部门',
    align:"center",
    dataIndex: 'useDepartmentName',
    width: '100px'
   },
   {
    title: '模具总寿命',
    align:"center",
    dataIndex: 'totalLife',
    width: '110px'
   },
   {
    title: '价格',
    align:"center",
    dataIndex: 'price',
    width: '80px'
   },
   {
    title: '启用日期',
    align:"center",
    dataIndex: 'enableDate',
    customRender:({text}) => !text?"":(text.length>10?text.substr(0,10):text),
    width: '120px'
   },
   {
    title: '验收日期',
    align:"center",
    dataIndex: 'acceptanceDate',
    customRender:({text}) =>!text?"":(text.length>10?text.substr(0,10):text),
    width: '120px'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark',
    width: '80px'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "使用部门",
      field: 'useDepartmentName',
      component: 'Input',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'code',
    component: 'Input',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入编码!'}]
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入!'}]
  },
  {
    label: '规格',
    field: 'spec',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '零件图号',
    field: 'partDrawingNo',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '零件',
    field: 'partName',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '维保冲次',
    field: 'maintenanceCharge',
    component: 'InputNumber',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入维保冲次!'}]
  },
  {
    label: '维保提前冲次',
    field: 'maintenanceForwardCharge',
    component: 'InputNumber',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入维保提前冲次!'}] 
  },
  {
    label: '维保周期',
    field: 'maintenanceCycle',
    component: 'InputNumber',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入维保周期!'}]
  },
  {
    label: '冲次系数',
    field: 'chargeCoefficient',
    component: 'InputNumber',
    colProps: {
        span: 8,
    },
  },
  {
    label: '模具总寿命',
    field: 'totalLife',
    component: 'InputNumber',
    colProps: {
        span: 8,
    },
  },
  {
    label: '单价',
    field: 'price',
    component: 'InputNumber',
    colProps: {
        span: 8,
    },
  },
  {
    label: '使用部门',
    field: 'useDepartmentName',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '库位编码',
    field: 'warehouseCode',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '仓位',
    field: 'warehouseName',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '生产厂家',
    field: 'manufacturerName',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '验收日期',
    field: 'acceptanceDate',
    component: 'DatePicker',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入验收日期!'}]   
  },
  {
    label: '启用日期',
    field: 'enableDate',
    component: 'DatePicker',
    colProps: {
        span: 8,
    },
    dynamicRules: () => [{ required: true, message: '请输入启用日期!'}]  
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    colProps: {
        span: 8,
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'Select',
    colProps: {
        span: 8,
    },
    componentProps:{
      options: [
        { label: '上线', value: 0 },
        { label: '空闲', value: 1 },
        { label: '维保', value: 2 },
        { label: '报废', value: 3 }
      ]
     },
    dynamicRules: () =>  [{ required: true, message: '请选择状态'}]
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}